local v = {x=0,y=0,z=0}
local function setvec(vec, x, y, z)
  vec.x = x
  vec.y = y
  vec.z = z
  return vec
end

local time = 0

local tex = "unknown_object.png"
minetest.register_entity(":entity:test", {
	initial_properties = {
		visual = "mesh",
		mesh = "propeller.obj",
		textures = {tex, tex, tex, tex, tex, tex},
		automatic_rotate = 20,
	},
	on_punch = function(self)
		self.object:remove()
	end,
	on_step = function(self, dtime)
		time = time + dtime
		if time >= 3 then
			time = 0
			self.object:set_rotation(setvec(v,2*math.pi*math.random(),0,0))
		end
	end,
})

minetest.register_chatcommand("entitytest", {
	func = function(name)
		local pos = minetest.get_player_by_name(name):get_pos()
		pos.x = pos.x + 2
		pos.y = pos.y + 1 
		minetest.add_entity(pos, "entity:test")
	end,
})
